package com.huashi.dealer.modular.business.order.param;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * API订单响应参数
 *
 * @author 谭陈强
 * @since 2025-07-30
 */
@Data
@Schema(description = "API订单响应参数")
public class OrderResponseParam {

    @Schema(description = "订单ID")
    private Long orderId;

    @Schema(description = "订单号")
    private String orderNo;

    @Schema(description = "订单总金额")
    private BigDecimal totalPrice;

    @Schema(description = "订单实付金额")
    private BigDecimal orderPrice;

    @Schema(description = "优惠券抵扣金额")
    private BigDecimal couponMoney;

    @Schema(description = "积分抵扣金额")
    private BigDecimal pointsMoney;

    @Schema(description = "运费")
    private BigDecimal deliveryMoney;

    @Schema(description = "订单状态：10待付款，20待发货，30待收货，40已完成，50已取消")
    private Integer orderStatus;

    @Schema(description = "支付状态：10未支付，20已支付")
    private Integer payStatus;

    @Schema(description = "支付方式：10基本账户，30返利账户，40核销账户")
    private Integer payType;

    @Schema(description = "订单来源：10普通订单，30返利订单，40核销订单")
    private Integer source;

    @Schema(description = "支付时间")
    private LocalDateTime payTime;

    @Schema(description = "发货时间")
    private LocalDateTime deliveryTime;

    @Schema(description = "收货时间")
    private LocalDateTime receivedTime;

    @Schema(description = "取消时间")
    private LocalDateTime cancelTime;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "订单备注")
    private String remark;

    @Schema(description = "收货地址信息")
    private AddressInfo addressInfo;

    @Schema(description = "商品列表")
    private List<OrderGoodsInfo> goodsList;

    @Schema(description = "订单列表")
    private List<OrderInfo> orderList;

    @Schema(description = "订单详情")
    private OrderInfo orderDetail;

    @Schema(description = "支付信息")
    private PaymentInfo payment;

    @Schema(description = "订单统计")
    private OrderStatistics statistics;

    @Schema(description = "总数")
    private Long total;

    @Schema(description = "当前页")
    private Integer currentPage;

    @Schema(description = "每页数量")
    private Integer perPage;

    @Schema(description = "最后页")
    private Integer lastPage;

    @Data
    @Schema(description = "收货地址信息")
    public static class AddressInfo {
        @Schema(description = "地址ID")
        private Long addressId;

        @Schema(description = "收货人姓名")
        private String name;

        @Schema(description = "收货人电话")
        private String phone;

        @Schema(description = "详细地址")
        private String detail;

        @Schema(description = "省市区")
        private String region;

        @Schema(description = "是否默认地址")
        private Boolean isDefault;
    }

    @Data
    @Schema(description = "订单商品信息")
    public static class OrderGoodsInfo {
        @Schema(description = "商品ID")
        private Long goodsId;

        @Schema(description = "商品SKU ID")
        private Long goodsSkuId;

        @Schema(description = "商品名称")
        private String goodsName;

        @Schema(description = "商品图片")
        private String goodsImage;

        @Schema(description = "商品规格")
        private String goodsSpec;

        @Schema(description = "商品数量")
        private Integer goodsNum;

        @Schema(description = "商品单价")
        private BigDecimal goodsPrice;

        @Schema(description = "商品总价")
        private BigDecimal goodsTotalPrice;

        @Schema(description = "商品分类")
        private Integer categoryId;
    }

    @Data
    @Schema(description = "订单信息")
    public static class OrderInfo {
        @Schema(description = "订单ID")
        private Long orderId;

        @Schema(description = "订单号")
        private String orderNo;

        @Schema(description = "订单总金额")
        private BigDecimal totalPrice;

        @Schema(description = "订单实付金额")
        private BigDecimal orderPrice;

        @Schema(description = "优惠券抵扣金额")
        private BigDecimal couponMoney;

        @Schema(description = "积分抵扣金额")
        private BigDecimal pointsMoney;

        @Schema(description = "运费")
        private BigDecimal deliveryMoney;

        @Schema(description = "订单状态：10待付款，20待发货，30待收货，40已完成，50已取消")
        private Integer orderStatus;

        @Schema(description = "支付状态：10未支付，20已支付")
        private Integer payStatus;

        @Schema(description = "支付方式：10基本账户，30返利账户，40核销账户")
        private Integer payType;

        @Schema(description = "订单来源：10普通订单，30返利订单，40核销订单")
        private Integer source;

        @Schema(description = "支付时间")
        private LocalDateTime payTime;

        @Schema(description = "发货时间")
        private LocalDateTime deliveryTime;

        @Schema(description = "收货时间")
        private LocalDateTime receivedTime;

        @Schema(description = "取消时间")
        private LocalDateTime cancelTime;

        @Schema(description = "创建时间")
        private LocalDateTime createTime;

        @Schema(description = "更新时间")
        private LocalDateTime updateTime;

        @Schema(description = "订单备注")
        private String remark;

        @Schema(description = "收货地址信息")
        private AddressInfo addressInfo;

        @Schema(description = "商品列表")
        private List<OrderGoodsInfo> goodsList;
    }

    @Data
    @Schema(description = "支付信息")
    public static class PaymentInfo {
        @Schema(description = "支付方式")
        private String payType;

        @Schema(description = "支付金额")
        private BigDecimal payAmount;

        @Schema(description = "支付时间")
        private LocalDateTime payTime;

        @Schema(description = "支付状态")
        private String payStatus;

        @Schema(description = "微信支付参数")
        private Object wxPayParams;
    }

    @Data
    @Schema(description = "订单统计")
    public static class OrderStatistics {
        @Schema(description = "总订单数")
        private Integer totalOrders;

        @Schema(description = "待付款订单数")
        private Integer pendingPayment;

        @Schema(description = "待发货订单数")
        private Integer pendingDelivery;

        @Schema(description = "待收货订单数")
        private Integer pendingReceive;

        @Schema(description = "已完成订单数")
        private Integer completed;

        @Schema(description = "已取消订单数")
        private Integer cancelled;

        @Schema(description = "总金额")
        private BigDecimal totalAmount;

        @Schema(description = "本月订单数")
        private Integer monthOrders;

        @Schema(description = "本月金额")
        private BigDecimal monthAmount;
    }
} 